<?php

//  get functions
require( dirname(__FILE__) . '/gn.php' );
require( dirname(__FILE__) . '/gn_print_option_page.php' );

// Prepare for localization
load_theme_textdomain ('german_newspaper');

//  load CSS for theme option page
//	add_action('admin_init','gn_load_css');
add_action('admin_head', 'gn_load_css');

//  second way to load a css file for the admin area
//	wp_admin_css( 'name', true );


//  register sidebars
if ( function_exists('register_sidebar') )
	register_sidebar(array(
		'name' => 'Left_Menu',
		'id' => 'Left_Menu',
		'before_widget' => '<li>',
		'after_widget' => '</li>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));

if ( function_exists('register_sidebar') )
	register_sidebar(array(
		'name' => 'Right_Menu',
		'id' => 'Right_Menu',
		'before_widget' => '<li>',
		'after_widget' => '</li>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));

	add_option( 'gn_left_img', get_template_directory_uri() . '/news-images/cuyabeno.jpg' );
	add_option( 'gn_right_img', get_template_directory_uri() . '/news-images/waterfall3.jpg' );
	add_option( 'gn_page_exclude', '' );
	add_option( 'gn_screen_width', '1024' );
	add_option( 'gn_body_color', '#333' );
	add_option( 'gn_body_background', 'silver' );
	add_option( 'gn_wrapper_background', 'white' );
	add_option( 'gn_screen_width', 'on' );
	add_option( 'gn_tab_feature_b1', 'off' );
	add_option( 'gn_tab_feature_b2', 'off' );
	add_option( 'gn_tab_count_b1', '3' );
	add_option( 'gn_tab_count_b2', '3' );
	
  add_action( 'admin_menu', 'gn_add_theme_option_page' );

	check_tab_feature();
	
	check_screen_width();


////////////////////////////////////////////////////////////////////////////////
// register theme option page
////////////////////////////////////////////////////////////////////////////////

function gn_add_theme_option_page()
{
	add_theme_page(__('German Newspaper Options'), __('German Newspaper Options'), 'edit_themes', basename(__FILE__), 'gn_theme_option_page');
}

function gn_theme_option_page()
{
	global 	$tab_feature_b1,
	        $tab_feature_b2,
	        $tab_count_b1,
	        $tab_count_b2,
	        $screen_width;

	if ( isset( $_POST['info_update'] ) )
	{
		//  call update function
		update_gn_options();
	}

	gn_print_option_page();
}



////////////////////////////////////////////////////////////////////////////////
// remove all widgets from all sidebars
////////////////////////////////////////////////////////////////////////////////
function gn_remove_all_widgets()
{
	global $wpdb;
	
	$sql_stmt = "DELETE FROM $wpdb->options WHERE option_name = 'sidebars_widgets'";
	
	$sql_rc = $wpdb->query( $sql_stmt );
}

?>